#include<QCoreApplication>
#include<QList>
#include<QDebug>
int removeDuplicates(QList<int> &nums);
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QList<int> nums1,nums2;
    int L;
    nums1<<1<<2<<3<<3<<4<<4<<5;//CASE1
    nums2<<8<<8<<8<<8<<8<<8<<8;//CASE2
    L=removeDuplicates(nums1);
    qDebug()<<nums1;
    qDebug()<<"The Length is"<<L;
    L=removeDuplicates(nums2);
    qDebug()<<nums2;
    qDebug()<<"The Length is"<<L;
    return a.exec();
}
int removeDuplicates(QList<int> &nums)
{
    int First,Last,n;
    for (int i = 0; i < nums.length(); i++)
    {
        First=nums.indexOf(nums.at(i));
        Last=nums.lastIndexOf(nums.at(i));
        if (First!=Last)
        {
            n=nums.at(i);
            nums.removeAll(nums.at(i));
            nums.insert(First,n);
        }
    }
    return nums.length();
}
